<include file="Layout/header" />
<body>
<div class="breadcrumbs" id="breadcrumbs"> 
  <script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>
  <ul class="breadcrumb">
    <li> <i class="icon-home home-icon"></i> <a href="{:U('Admin/Index/welcome')}">首页</a> </li>
    <li class="active">首页幻灯片</li>
  </ul>
</div>
<div class="page-content">
  <div class="page-header">
    <h1> 系统设置 <small> <i class="icon-double-angle-right"></i> 首页幻灯片 </small> </h1>
  </div>
  <!-- /.page-header -->
  
  <div class="row">
    <div class="col-sm-4">
      <div class="widget-box">
        <div class="widget-header widget-header-flat">
          <h4 class="smaller"> <i class="icon-quote-left smaller-80"></i>添加幻灯片</h4>
        </div>
        <div class="widget-body">
          <div class="widget-main">
            <form class="form-horizontal" action="{:U('Admin/Setting/adv')}" id="validation-form" method="post" enctype="multipart/form-data">
              <input type="hidden" name="adv_id" value="{$id}"/>
              <input type="hidden" name="old_pic" value="{$banner.adv_pic}"/>
              <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="adv_name">幻灯片名称:</label>
                <div class="col-xs-12 col-sm-9">
                  <div class="clearfix">
                    <input type="text" id="adv_name" name="adv_name" value="{$banner.adv_name}" class="col-xs-12 col-sm-5" />
                  </div>
                </div>
              </div>
			  <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="adv_name">幻灯片位置:</label>
               <div class="col-xs-12 col-sm-9">
                         
                          <div>
                            <label class="blue">
                              <input name="adv_site" value="0" type="radio" class="ace" <?php if($banner['adv_site']==0){?> checked=""<?php }?>>
                              <span class="lbl"> PC</span> </label>
                          </div>
						   <div>
                            <label class="blue">
                              <input name="adv_site" value="1" type="radio"<?php if($banner['adv_site']==1){ ?> checked="" <?php }?> class="ace">
                              <span class="lbl"> WEB</span> </label>
                          </div>
                        </div>
              </div>
              <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="adv_sort">排序:</label>
                <div class="col-xs-12 col-sm-9">
                  <div class="clearfix">
                    <input type="text" id="adv_sort" name="adv_sort" value="{$banner.adv_sort}" class="col-xs-12 col-sm-5" />
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="adv_url">链接地址:</label>
                <div class="col-xs-12 col-sm-9">
                  <div class="clearfix">
                    <input type="text" id="adv_url" name="adv_url" value="{$banner.adv_url}" class="col-xs-12 col-sm-5" />
                  </div>
                </div>
              </div>
              <div class="hr hr-dotted"></div>
              <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="adv_pic">幻灯片图片:</label>
                <div class="col-xs-12 col-sm-9">
                  <div class="clearfix">
                    <input type="file" id="id-input-file-2" name="file" />
                    <if condition="$banner.adv_pic neq ''"> <img src="/data/upload/banner/{$banner.adv_pic}" width="200" height="100"/> </if>
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right"></label>
                <div class="col-xs-12 col-sm-9"><input class="btn btn-primary radius" type="submit" id="submitBtn" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"></div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-8">
      <div class="row">
        <div class="col-xs-12">
          <div class="widget-box">
            <div class="widget-header widget-header-flat">
              <h4 class="smaller">幻灯片列表</h4>
            </div>
            <div class="widget-body">
              <div class="widget-main">
                <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                  <thead>
                    <tr>
                      <th>幻灯片名</th>
                      <th class="hidden-480">排序</th>
                      <th>url </th>
                      <th>操作</th>
                    </tr>
                  </thead>
                  <tbody>
                    <foreach name="bannerall" item="val">
                      <tr class="selected">
                        <td><img src="/data/upload/banner/{$val.adv_pic}" width="100" height="50"/><span style="padding: 5px;">{$val.adv_name}</span></td>
                        <td class="hidden-480">{$val.adv_sort}</td>
                        <td>{$val.adv_url}</td>
                        <td><div class="visible-md visible-lg hidden-sm hidden-xs btn-group"> <a class="btn btn-xs btn-info" href="{:U('Admin/Setting/adv')}/id/{$val.id}"> <i class="icon-edit bigger-120"></i> </a> <a class="btn btn-xs btn-danger" onClick="adv_del(this,{$val.id})"> <i class="icon-trash bigger-120"></i> </a> </div></td>
                      </tr>
                    </foreach>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <input type="hidden" value="{:U('Admin/Setting/adv_del')}" id="adv_del">
  <!-- /.row --> 
</div>
<!-- /.page-content --> 

<!-- /#ace-settings-container --> 
<!--[if !IE]> -->

		<script src="/Public/Admin/js/jquery-2.0.3.min.js"></script>

		<!-- <![endif]--> 

<!--[if IE]>
<script src="/Public/Admin/js/jquery-2.0.3.min.js"></script>
<![endif]--> 

<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='/Public/Admin/js/jquery-2.0.3.min.js'>"+"<"+"script>");
		</script>

		<!-- <![endif]--> 

<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='/Public/Admin/js/jquery-1.10.2.min.js'>"+"<"+"script>");
</script>
<![endif]--> 

<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='/Public/Admin/js/jquery.mobile.custom.min.js'>"+"<"+"script>");
		</script> 
<script src="/Public/Admin/js/bootstrap.min.js"></script> 
<script src="/Public/Admin/js/typeahead-bs2.min.js"></script> 

<!-- page specific plugin scripts --> 

<!--[if lte IE 8]>
		  <script src="/Public/Admin/js/excanvas.min.js"></script>
		<![endif]--> 

<!-- ace scripts --> 

<script src="/Public/Admin/js/ace-elements.min.js"></script> 
<script src="/Public/Admin/js/ace.min.js"></script> 
<script src="__ADMIN_JS__/jquery.validate.min.js"></script> 
<script src="__ADMIN_JS__/bootbox.js"></script> 
<script type="text/javascript">
			 
$(document).ready(function(){
                $('#id-input-file-2').ace_file_input({
					no_file:'没有选择文件',
					btn_choose:'选择',
					btn_change:'更改',
					droppable:false,
					onchange:null,
					thumbnail:false //| true | large
					//whitelist:'gif|png|jpg|jpeg'
 					//blacklist:'exe|php'
					//onchange:''
					//
				});

	
    $("#submitBtn").click(function(){ 
         $("#validation-form").submit();
    });
	$('#validation-form').validate({
		errorElement: 'div',
		errorClass: 'help-block',
		focusInvalid: false,
        rules : {
        	            adv_name: {
							required: true
 						},
 						adv_url: {
							url:true
						} 
						 
        },
        messages : {
      		            adv_name: {
							required: "幻灯名称不能为空.",
 						},
						adv_url: {
							url: "请输入合法url"
						} 
						 
        },
		 
			
					highlight: function (e) {
						$(e).closest('.form-group').removeClass('has-info').addClass('has-error');
					},
			
					success: function (e) {
						$(e).closest('.form-group').removeClass('has-error').addClass('has-info');
						$(e).remove();
					},
			
					errorPlacement: function (error, element) {
						if(element.is(':checkbox') || element.is(':radio')) {
							var controls = element.closest('div[class*="col-"]');
							if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
							else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
						}
						else if(element.is('.select2')) {
							error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
						}
						else if(element.is('.chosen-select')) {
							error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
						}
						else error.insertAfter(element.parent());
					},
			
					submitHandler: function (form) {
						$(form).ajaxSubmit();
			            var index = parent.layer.getFrameIndex(window.name);
			            //parent.$('.btn-refresh').click();
			            parent.layer.close(index);
					}
					 
    });
});
		</script> 
<script type="text/javascript">
     /*文章-删除*/
function adv_del(obj,id){
	var host=$("#adv_del").val();
      bootbox.setLocale("zh_CN");  
      bootbox.confirm("确定删除该banner?", function(result) {  
        if (result) {  
           $.ajax({
			url:host,
			type:"POST",
			dataType:"json",
			data:{id:id},
			success: function(s){
 				if(s.status == 1){
				$(obj).parents("tr").remove();
				bootbox.alert('删除成功');
				}else{
				bootbox.alert(s.info);	
					}
				}
			})
		
		 
        }  
      });  
 
}
</script>
</body>
</html>